package com.lei.springbootpractice.controller;

import com.lei.springbootpractice.pojo.UserPojo;
import com.lei.springbootpractice.service.UserService;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/courier")
public class CourierController {

    @Autowired
    private UserService userService;

    @GetMapping("/dashboard")
    public String dashboard(HttpSession session, Model model) {
        String userID = (String) session.getAttribute("loggedInUser");
        UserPojo user = userService.getUserByUserID(userID);

        model.addAttribute("username", user.getUserName());
        model.addAttribute("role", "快递员");
        return "courier/dashboard";
    }

    @GetMapping("/tasks")
    public String deliveryTasks(Model model) {
        // 快递任务查询逻辑
        return "courier/task-list";
    }
}